<?php


/**
 * +-------------------------------------------------------------
 * |Caption:
 * +-------------------------------------------------------------
 * |Author: Lenny
 * +-------------------------------------------------------------
 * |Email:  1685964109@qq.com
 * +-------------------------------------------------------------
 * |Date:   2024-03-12 09:42
 * +-------------------------------------------------------------
 */

use app\admin\middleware\CheckDomain;
use think\facade\Route;
use app\admin\middleware\LoginLimit;
use app\admin\middleware\Token;

//登录
Route::group('login', function () {
    Route::post('login', 'login/login');//登录
//    Route::post('login', 'login/login')->middleware(LoginLimit::class);//登录
    Route::get('captcha', 'login/captcha');//验证码
});


//用户管理
Route::group('user', function () {
    Route::post('list', 'User/List');//列表
    Route::post('create', 'User/add');//添加
    Route::post('modify', 'User/edit');//修改
    Route::post('modify_status', 'User/edit');//修改
    Route::post('del', 'User/del');//删除
})->middleware(Token::class);


//商品
Route::group('goods', function () {
    Route::post('list', 'Goods/List');//列表
    Route::post('create', 'Goods/add');//添加
    Route::post('modify', 'Goods/edit');//修改
    Route::post('details', 'Goods/detail');//详情
    Route::post('modify_status', 'Goods/editStatus');//修改状态
    Route::post('del', 'Goods/del');//管理员删除
    Route::group('cate', function () {
        Route::post('list', 'Cate/List');//分类列表
        Route::post('create', 'Cate/add');//分类添加
        Route::post('modify', 'Cate/edit');//分类修改
        Route::post('modify_status', 'Cate/editStatus');//分类修改
        Route::post('details', 'Cate/detail');//分类详情
        Route::post('del', 'Cate/del');//分类删除
    });
})->middleware(Token::class);


//订单
Route::group('order', function () {
    Route::post('list', 'Order/List');//列表
    Route::post('details', 'Order/detail');//详情
    Route::post('del', 'Order/del');//删除
})->middleware(Token::class);

//检索框
Route::group('select', function () {
    Route::post('user', 'search/user');//列表
    Route::post('goods', 'search/goods');//列表
})->middleware(Token::class);

//上传
Route::rule('upload/:action','upload/:action')->middleware(CheckDomain::class); //该中间件用于检测当前域名是否合法
